refactored main, looks much nicer now and dont parse source twice