adding docs for better code completion
refactoring out the different bits
refactoring out the common bits