Basic functions rough draft finished