cleaned up code-structure a bit