Could this be broken into more functions for each piece?