cleaned up and compacted code
compacted much code