more efficent solution