Added logic to handle marking attendance