removed an unnecessary condition check
changed code to improve performance