added some doctrings and functions