slightly organized code