Cleaned up code, removed redundant repeats