First attempt at implementing functions