functions.sql added + some action changes