Minimized Code from 32 lines to 23