 
 		# We have a file that doesn't exist, respond with 404
 		if !exists
-			fs.readFile(path.join(process.cwd(), '/public/404.html'), (err, file) ->
-				response.writeHead(404)
-				response.write(file, 'binary')
-				response.end()	
-			)
+			respond404(request, response)
+
 			return
 
 		# We have a directory, see if we have a static index file

fs = require 'fs'
url = require 'url'

exports.handle = (request, response) ->
	uri = url.parse(request.url).pathname
	filename = path.join(process.cwd(), '/public/' + uri)

			if fs.existsSync(path.join(filename, 'index.html'))
				filename = path.join(filename, 'index.html')
			else
				respond404()
				return

		fs.readFile(filename, "binary", (err, file) ->
			#Something went wrong when reading file
			if err
				respond500(request, response)
				return
			
			# Everything went well, return
			response.writeHead(200)
			response.write(file, "binary")
