refactored peeks, made more general
minor formatting