doing this with a lot less code