Moved all function code into Function

No more blocks in function creation. It's not necessary.