More readable

Added Main loop, better function names and arguments