make improvements and separated out compile