Added scrollfuction on output

Also cleaned up the code a bit