final code for system