putting everything (very messy structure written based on SDK demo)