Main functionality
added documentation