more elegent solution