added code to be more efficient