add documentation, remove locals() reference