Cleaned up code

With help from @TotempaaltJ