Made my code not redundant