Trying to simplify a bit

also added some documentation