Resolved some issues with scope and repeated errors