split things into smaller files and bug fixing