Cleaned up code as advised by @drbyte