second attempt at code