cleaned out complex subroutines