changed cost function, cleaned code

temporary placeholders