better way of doing it