reduced redundant code; marked problem in code