cleaned up scope of local vars