moved some variables around for better code readability