simplified by removing redundant code